Ê




Here is SwitchBeep, the beep randomizer for the Sound cdev.

The Sound cdev uses snd resources in the System or Suitcase to replace the normal dull beep with a piece of digitized sound.  Many cool people have many cool sounds available in their Sound cdev.  Truly cool people have edited item 11 of the DITL in the Sound cdev to have dimensions like  22,158,253,313 so that they can see more than five sounds at a time.

Well, picking your own beep is nice, but since I have a large selection of beeps, I want a different one each day.  BeepShuffle, another INIT, changes the beep at EVERY beep which is a bit too often for me.  In addition, this provided no way to eliminate beeps which were inappropriate or too long.  It also involved another patch to SysBeep, and patches can sometimes lead to trouble.

SwitchBeep has none of these difficulties.  It simply reads the location where the current beep is stored (it's in the extended PRAM of the Plus and later machines) and changes it to a different snd id number.  It reads the disk for some of the snds but it patches nothing and allocates no permanent memory.  It must run after Suitcase or Master Juggler, but the way it is named it will.

SwitchBeep will not work with SoundMaster or BeepINIT.  It only works if you are using snd resources and the Sound cdev.  If you want to randomize sounds in the others INITs, use my Randomizer INIT which is available in fine archives everywhere.  SwitchBeep will not run on a 512E, as Sound and Map wonÕt, due to the lack of extended PRAM.

SwitchBeep is a Control Panel Document, also known as an cdev, so it is accessed through the Control Panel DA.  However, it needs very little control.  It just works.  It does have one adjustable feature, and that is a list of beeps that SwitchBeep will use.  If you donÕt want a sound to be used as a beep, deselect it from the list. Changes to the list are reversable with Undo until you click on the new beep icon or close the cdev. If you click the speaker icon in the middle of the window, the beep will change randomly.  This random beep is also undo-able.  You can change it as many times as you like.  The name of the current beep is displayed so that you donÕt have to click on the SwitchBeep logo to hear it unless you want to.  The text below the list toggles if clicked and displays my name and address and the ubiquitous plea for money.  If you hold the Option key down when clicking on a sound name, SwitchBeep will display the name momentarily while it plays the sound.  If you hold the Command key down then the beep you click on will become the beep, regardless of whether it is hilighted or not.  This is also undo-able.  If you donÕt like my cursor you can hold the option key down while initially selecting SwitchBeep from the list of Control Panel devices to get the standard arrow cursor.

There is also a SwitchBeep FKEY included.  The SwitchBeep cdev MUST be present in the System Folder for the SwitchBeep FKEY to work.  The FKEY must be installed either into the System file or via Suitcase or Juggler.  The current ID is 12 so it must be either renumbered with ResEdit or used via QuickKeys or MacroMaker (a piece of crap from Apple that Jean Louis GassŽ apologized for creating).

This cdev/INIT combo was very difficult to do since the Sound cdev is completely undocumented.  I ended up disassembling it to find the proper calls to make and came up with these two crucial definitions:

FUNCTION GetBeep: Integer; INLINE $204F, $203C, $0002, $007C, $A051;

PROCEDURE SetBeep (theBeep: Integer); INLINE $204F, $203C, $0002, $007C, $A052;

These were the heart of the problem and can be used in any program to control the beep as done by the Sound cdev.  Of course, these are reserved for Apple use and subject to change without notice, but I donÕt expect them to change real soon, if at all.

I used Lightspeed Pascal to do my initial prototyping and to write the INIT while I used MPW Pascal to write the cdev.   I still havenÕt found the magical incantation to get MPW Pascal to work for writing an INIT and it really chafes my buns, but since I can get it to work in LSP I wonÕt whine any more about it here.  I find LSP to be very useful for prototyping but weak in the development area since you must use ResEdit to copy stuff to the proper files.  MPW will slap everything into the proper place and even throw a copy into the system folder for testing.  It is heaven for programmers.

Feel free to send money, praise, comments, complaints, and insults to me.

Jon Pugh
PO Box 5509 L561
Livermore, CA 94550
(415) 423-4239
pugh@ccc.nmfecc.gov

Modification History:

1.0 First release.
1.1 Changed check for sounds to not load all snd resources.  Much faster with less IO.
1.2 Became a cdev so we could randomize the beep on demand.  Added list and removed size limit.
1.3 Added ability to play sounds with Option key and control over cursor.
1.3.1 Fixed problem with only having one sound installed or selected.
1.4 Added ability to choose the beep.
1.4.1 Converted INIT to MPW and incorporated fixes for limited selections.
1.5 Rewrote INIT to better check match of beep list and existing beeps.
1.5.1 Again I fixed the problem with having 1 beep selected.  Also fixed a problem with the FKEY to check the Random result.